package com.hiwetop.cp;

import com.google.gson.Gson;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;

import java.util.Set;

/**
 * Created by linyu on 2016/12/12.
 */
public class CookieUtil {
    private static Set<Cookie> cookies= null;

    public static void setCookie(WebDriver driver){
        System.out.println(new Gson().toJson(cookies));
        for (Cookie cookie:cookies
             ) {
            driver.manage().addCookie(cookie);
        }
    }

    public static Set<Cookie> getCookie(WebDriver driver) {
        cookies = driver.manage().getCookies();
        System.out.println(new Gson().toJson(cookies));
        return driver.manage().getCookies();
    }
}
